<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>添加银行卡</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css文件-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->

</head>
<body>
<div class="zz-header">
    请绑定收款人本人名下储蓄卡
</div>
<div class="zz-list">
    <ul>
        <li>
            <span class="zz-left">持卡人姓名</span
            ><span class="zz-right zz-payee"></span>
            <span class="zz-explain-icon"></span>
        </li>
        <li>
            <span class="zz-left">身份证号码</span
            ><span class="zz-right zz-payeeId"></span>
        </li>
        <li>
            <span class="zz-left">银行卡卡号</span
            ><input class="zz-code-num zz-bank-code" type="tel" placeholder="请输入收款人名下的储蓄卡卡号" maxlength="19"/>
        </li>
    </ul>
</div>
<div class="zz-explain" style="display: none">
    <p class="zz-phone-explain">持卡人说明</p>
    <div class="zz-bank-reserve">为了保证账户资金安全，只能绑定签约收款人本人名下的储蓄卡，若需修改收款人信息请联系业务员。</div>
    <span class="zz-know">知道了</span>
</div>
<div class="zz-mask" style="display: none"></div>
<input class="footer zz-footTop" type="button" value="下一步">
</body>


<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript">

</script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">
    var queryURLParameter = utils.queryURLParameter();
    var page = "billMsg";
    var data = '';
    
    function bindHTML() {
        var reg = /^(.{4})(.*)(.{4})$/,
                payeeInidcard = data["payeeInidcard"],
                payee = reg.exec(payeeInidcard),
                payeeId = payee[1] + " **** **** " + payee[3];

        $(".zz-payeeId").html(payeeId);
        $(".zz-payee").html(data["payeeName"]);
    }
    //初始化接口
    $.ajax({
        type: 'get',
        async: false,
        url: utils.ajaxUrl()+"h5/settlementController/queryPayee",
        success: function (res) {
        	var res = JSON.parse(res);
        	console.log(res);
            if (res && res.retCode == "0000") {
                data = res["storeInf"];
                bindHTML()
            } else {
            	$footer.attr("disabled", "true");
                new $.modal({
                    content: res.retMsg,//弹框内容
                    showcontent: true,//false为弹出框组件二，true为弹出框组件一
                }).show();
            }
        }
    });


    $know.click(function () {
        $(".zz-explain .zz-phone-explain").html("持卡人说明");
        $(".zz-explain .zz-bank-reserve").html("为了保证账户资金安全，只能绑定签约收款人本人名下的储蓄卡，若需修改收款人信息请联系业务员。");
        $(".zz-explain .zz-know").html("知道了");
        $explain.hide();
        $mask.hide();
		$footer.removeAttr("disabled");
    });

    $footer.click(function () {
        //判断银行卡长度
        if (!utils.effectiveCard($bank_code.val(), $footer)) {
            return false
        }
        var bankAccount = utils.removeSpace($bank_code.val());
        
        new $.modal({
            content: "加载中",
            animation: true//调用动画
        }).show();
        
        //$footer.attr("disabled", "true");
        //添加银行卡—校验银行卡接口
        $.ajax({
            url: utils.ajaxUrl()+"h5/settlementController/checkCard",
            async: false,
            data: {
                bankAccount: bankAccount
            },
            type: 'get',
            success: function (res) {
             	var res = JSON.parse(res);
             	//console.log(res);
                if (res && res.retCode == '0000') {
                    window.location.href = "../../html/h5/msgAuthentication.html?bankAccount=" + bankAccount + "&binBankId=" + res.binBankId + "&binBankName=" + res.binBankName+ "&change=" + queryURLParameter.change + "&page=" + page;
                    //$footer.removeAttr("disabled");
                    new $.modal({
            			animation: true,//调用动画
        			}).hide();
                } else {
                	new $.modal({
            			animation: true,//调用动画
        			}).hide(0);
                	$footer.attr("disabled", "true");
                    $(".zz-explain .zz-phone-explain").html("提示");
                    $(".zz-explain .zz-bank-reserve").html(res.retMsg);
                    $(".zz-explain .zz-know").html("确认");
                    $explain.show();
                    $mask.show();
                    
                }
            }
        });
    })

</script>
</html>